<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>添加客户</title>
<script>

	function markAsFinished(button, id) {
		document.getElementById(id).value = formatDate(new Date());
		button.disabled = true;
	}
</script>

<script>

	$(document).ready(function() {
		$("#loginName").focus();
		
		$("#inputForm").validate({
			rules: {
				name: {
					required: true,
					remote: "${ctx}/customer/checkName?oldName=" + encodeURIComponent('${customer.name}')
				}
			},
			messages: {
				name: {
					remote: "客户名已存在"
				}
			}
		});
	});
</script>
</head>

<body>
	<form:form id="inputForm" modelAttribute="customer"
		action="${ctx}/customer/save/${customer.id}" method="post">
		<input type="hidden" name="id" value="${customer.id}" />
		<fieldset class="prepend-top">
			<c:if test="${not empty add }"><legend>编辑客户资料</legend></c:if>
			<c:if test="${empty add}">
			<legend>添加新客户</legend>
				<div>
					<label for="uid" class="field">ID:</label> <input
						disabled="disabled" type="text" id="uid" name="uid" size="40"
						value="${customer.id}" />
				</div>
			</c:if>
			<div>
				<label for="name" class="field">客户名称:</label> <input
					type="text" id="name" name="name" size="40"
					value="${customer.name}" />
			</div>
			<div>
				<label for="address" class="field">地址:</label> 
				<input type="text" id="address" name="address" size="40" value="${customer.address}" />
			</div>
			<div>
				<label for="contact1" class="field">联系方式1:</label> 
				<input type="text" id="contact1" name="contact1" size="40" value="${customer.contact1}" />
			</div>
			<div>
				<label for="contact2" class="field">联系方式2:</label> 
				<input type="text" id="contact1" name="contact1" size="40" value="${customer.contact2}" />
			</div>
			<div>
				<label for="remark" class="field">备注:</label> 
				<input type="text" id="remark" name="remark" size="40" value="${customer.remark}" />
			</div>
		</fieldset>
		<div>
			<input id="submit" class="button" type="submit" value="提交" />&nbsp;
			<input id="cancel" class="button" type="button" value="返回"
				onclick="history.back()" />
		</div>
	</form:form>
</body>
</html>
